/*
 * @Author: zi.yang
 * @Date: 2022-02-03 00:12:45
 * @LastEditors: zi.yang
 * @LastEditTime: 2022-02-08 20:08:34
 * @Description: In User Settings Edit
 * @FilePath: \api-generator\app\controller\login.js
 */
'use strict';

const Controller = require('egg').Controller;

class LoginController extends Controller {
  async index() {
    const { ctx } = this;
    await ctx.render('login.njk', { name: 'view test' });
  }

  async PostLogin() {
    const { ctx } = this;
    const result = await ctx.service.user.login(ctx.request.body);
    ctx.body = result;
  }

  async loginError() {
    const { ctx } = this;
    const opt = {
      layout: '../login.njk',
      state: 'error',
      msg: '用户名密码错误！',
    };
    await ctx.render('/notify/notify.njk', opt);
  }
}


module.exports = LoginController;
